package com.itkim.work.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 文件映射路径
 */
@Configuration
public class HttpConverterConfig implements WebMvcConfigurer {

    private static String filePath;

    @Value("${file.path}")
    public void getFilePath(String filePath){
        HttpConverterConfig.filePath = filePath;
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file/**").addResourceLocations("file:" + filePath);
    }
}
